package com.afterglow.example.consumer;

import com.afterglow.example.common.model.User;
import com.afterglow.example.common.service.UserService;
import com.afterglow.lcsrpc.bootstrap.ConsumerBootstrap;
import com.afterglow.lcsrpc.proxy.ServiceProxyFactory;
import lombok.extern.slf4j.Slf4j;


/**
 * Description:简易服务消费者示例
 * Date: 2024/12/08
 * author: lcs
 */
@Slf4j
public class ConsumerExample {

    public static void main(String[] args) throws InterruptedException {

        //服务消费者初始化
        ConsumerBootstrap.init();

        UserService userService = ServiceProxyFactory.getProxy(UserService.class);

        User user = new User();
        user.setName("lcs");
        for (int i = 0; i < 999; i++) {
            // 调用
            User newUser = userService.getUser(user);
            if (newUser != null) {
                System.out.println(newUser.getName());
            } else {
                System.out.println("user == null");
            }
        }

    }
}
